<?php session_start();?>

<?php
	/* 
	 Deletes a specific entry from the 'nganh' table
	*/
	
	 // connect to the database
	 include('Connect_DB.php');
	 include('Model.php');
	 
	 switch($_POST['cmd'])
	 {
	 	case "YES":  // check if the 'id' variable is set in URL, and check that it is valid
			if (isset($_SESSION['name']) && is_numeric($_SESSION['name'])) 
			 {
				 // get id value
				 $id = $_SESSION['name'];
				 
				 // Call function from file Model.php delete the entry
				 Delete_Nganh($id);
				 
				 // redirect back to the view page with (tag meta within HTML)
				echo "<meta http-equiv='refresh' content='0; url=./View_View_Nganh.php' />";
		
			 }
			  
			 break;
		case "NO":
			echo "<meta http-equiv='refresh' content='0; url=./View_View_Nganh.php' />";
	 		break;
	}

?>